package com.atguigu.crowd.mvc.handler;

import com.atguigu.crowd.entity.Admin;
import com.atguigu.crowd.entity.Student;
import com.atguigu.crowd.service.api.AdminService;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resources;
import java.util.List;

@Controller
public class Testhandler {
    @Autowired
    private AdminService adminService;

    private Logger logger=LoggerFactory.getLogger(this.getClass());


    @RequestMapping("/testSm.html")
    public String doTest(Model model){
        List<Admin> adminList = adminService.getAll();

        model.addAttribute("admins",adminList);
//        String a=null;
//        System.out.println(a.length());

        System.out.println(10/0);
        return "test";
    }

    @RequestMapping("/send/array.html")
    public String sendArray(@RequestBody List<Integer> array){
        for (Integer i:array){
            System.out.println(i);
        }
        return "test";
    }


    @ResponseBody
    @RequestMapping("/sendComposeObject.html")
    public String sendComposeObject(@RequestBody Student student){

        System.out.println(student);

        return "test";
    }

}
